home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / utils / dump.c < prev    next >
C/C++ Source or Header  |  1990-10-12  |  8KB  |  300 lines

  1. /* 
  2.  * dump.c --
  3.  *
  4.  *    Routines to print global system states in a readable form.  Examples
  5.  *    of structures that can be dumped are:
  6.  *
  7.  *        * timer queue
  8.  *        * process table
  9.  *        * queue of ready processes.
  10.  *
  11.  * Copyright 1985 Regents of the University of California
  12.  * All rights reserved.
  13.  */
  14.  
  15. #ifndef lint
  16. static char rcsid[] = "$Header: /sprite/src/kernel/utils/RCS/dump.c,v 9.11 90/10/11 21:59:59 kupfer Exp $ SPRITE (Berkeley)";
  17. #endif /* not lint */
  18.  
  19.  
  20. #include <net.h>
  21. #include <sprite.h>
  22. #include <mach.h>
  23. #include <dump.h>
  24. #include <dumpInt.h>
  25. #include <timer.h>
  26. #include <proc.h>
  27. #include <sys.h>
  28. #include <list.h>
  29. #include <devVid.h>
  30. #include <rpc.h>
  31. #include <fs.h>
  32. #include <fsutil.h>
  33. #include <fscache.h>
  34. #include <fspdev.h>
  35. #include <recov.h>
  36. #include <string.h>
  37. #include <sched.h>
  38. #include <devSyslog.h>
  39. #include <mem.h>
  40. #include <stdio.h>
  41.  
  42. /*
  43.  * Forward references to procedures internal to this file.
  44.  */
  45. static void    DumpProcTable _ARGS_((ClientData));
  46. static void    PrintL1Menu _ARGS_((ClientData));
  47. static void    PrintTOD _ARGS_((ClientData));
  48. static void    PrintVersion _ARGS_((ClientData));
  49. static void    ResetNetworks _ARGS_((ClientData));
  50. static void    VidEnable _ARGS_((ClientData));
  51.  
  52. /*
  53.  * Table of routines and their arguments to be called on dump events.
  54.  * Only machine independent dump events should be added to this table.
  55.  * Machine dependent event should be added to the Local event table.
  56.  */
  57. static EventTableType eventTable[] = {
  58.     {'/', PrintL1Menu, (ClientData)0, "Print Dump Event Menu"},
  59.     {'a', RESERVED_EVENT, NULL_ARG, "Abort to PROM monitor" }, 
  60. #ifdef notdef
  61.     {'b', RESERVED_EVENT, NULL_ARG, 
  62.                 "Put machine into (old) serial line debugger"},
  63. #endif
  64.     {'c', Fscache_DumpStats, (ClientData)0, "Dump cache stats"},
  65.     {'d', RESERVED_EVENT, NULL_ARG, "Put machine into the kernel debugger"},
  66.     {'e', Timer_DumpStats, (ClientData) 'e', "Dump timer stats"},
  67.     {'f', Fsutil_PrintTrace, (ClientData) -1, "Dump filesystem trace"},
  68.     {'i', Proc_KDump, (ClientData) 0, "Info on waiting processes"},
  69.     {'j', Dev_SyslogDisable, (ClientData) 0, "Disable/enable syslog"},
  70.     {'m', Mem_DumpStats, (ClientData) FALSE, "Dump memory stats"},
  71.     {'n', ResetNetworks, (ClientData)0, "Reset the network interfaces"},
  72.     {'o', VidEnable, (ClientData) 1, "Turn video on"},
  73.     {'p', DumpProcTable, (ClientData) 0, "Dump process table"},
  74.     {'r', Sched_DumpReadyQueue, (ClientData) 0, "Dump ready queue"},
  75.     {'q', Fspdev_PrintTrace, (ClientData) 200, "Dump pseudo-device trace"},
  76.     {'s', Timer_DumpStats,   (ClientData) 's', "Reset timer stats"},
  77.     {'t', Timer_DumpQueue,  (ClientData) 0, "Dump the timer queue"},
  78.     {'v', PrintVersion, (ClientData) 0, "Print version string of the kernel"},
  79.     {'w', Fsutil_SyncStub, (ClientData) FALSE, "WRITE BACK CACHE"},
  80.     {'x', Fsutil_HandleScavengeStub, (ClientData) 0, 
  81.                     "Scavenge filesystem handles"},
  82.     {'y', Recov_PrintTrace, (ClientData) 50, "Dump RPC recovery trace"},
  83.     {'z', Rpc_PrintTrace, (ClientData) 50, "Dump RPC packet trace"},
  84.     {'1', Timer_TimerGetInfo, (ClientData) 1,"Dump info for timer counter 1"},
  85.     {'2', Timer_TimerGetInfo, (ClientData) 2,"Dump info for timer counter 2"},
  86.     {'3', Timer_TimerGetInfo, (ClientData) 3,"Dump info for timer counter 3"},
  87.     {'4', Timer_TimerGetInfo, (ClientData) 4,"Dump info for timer counter 4"},
  88.     {'5', Timer_TimerGetInfo, (ClientData) 5,"Dump info for timer counter 5"},
  89.     {'6', PrintTOD,           (ClientData) 0,"Print time of day counters"},
  90.     /* This MUST be the last entry */
  91.     {'\0', LAST_EVENT,        NULL_ARG,       (char *) 0 },
  92. };
  93.  
  94.  
  95.  
  96. /*
  97.  *----------------------------------------------------------------------
  98.  *
  99.  * Dump_Init --
  100.  *
  101.  *    Establish default procedural attachments for Dump events.
  102.  *
  103.  * Results:
  104.  *    None.
  105.  *
  106.  * Side effects:
  107.  *    None. 
  108.  *
  109.  *----------------------------------------------------------------------
  110.  */
  111.  
  112. void
  113. Dump_Init()
  114. {
  115.     Dump_Register_Events(eventTable);
  116.  
  117. }
  118.  
  119.  
  120. /*
  121.  *----------------------------------------------------------------------
  122.  *
  123.  * DumpProcTable --
  124.  *
  125.  *    Wrapper to avoid casts and compiler warnings.
  126.  *
  127.  * Results:
  128.  *    None.
  129.  *
  130.  * Side effects:
  131.  *    (see Proc_Dump.)
  132.  *
  133.  *----------------------------------------------------------------------
  134.  */
  135.  
  136. /* ARGSUSED */
  137. static void
  138. DumpProcTable(dummy)
  139.     ClientData dummy;
  140. {
  141.     Proc_Dump();
  142. }
  143.  
  144. /*
  145.  *----------------------------------------------------------------------
  146.  *
  147.  * PrintL1Menu --
  148.  *
  149.  *    Dump out a list of the L1-key magic commands.
  150.  *
  151.  * Results:
  152.  *    None.
  153.  *
  154.  * Side effects:
  155.  *    None.
  156.  *
  157.  *----------------------------------------------------------------------
  158.  */
  159.  
  160. /* ARGSUSED */
  161. static void
  162. PrintL1Menu(arg)
  163.     ClientData arg;        /* unused */
  164. {
  165.     EventTableType    *entry;
  166.  
  167.     printf("Pressing the L1 key and a letter causes the following...\n");
  168.     printf("/ or ? - Print this menu\n");
  169.     for (entry = eventTable; entry->routine != LAST_EVENT; entry++) {
  170.     printf("%c - %s\n",entry->key, entry->description);
  171.     }
  172.     /*
  173.      * Show the machine dependent bindings.
  174.      */
  175.     printf("Machine dependent entries....\n");
  176.     Dump_Show_Local_Menu();
  177. }
  178.  
  179.  
  180. /*
  181.  *----------------------------------------------------------------------
  182.  *
  183.  * PrintTOD --
  184.  *
  185.  *    Prints the time of day using one of two sources for the time.
  186.  *
  187.  * Results:
  188.  *    None.
  189.  *
  190.  * Side effects:
  191.  *    Output is written to the display.
  192.  *
  193.  *----------------------------------------------------------------------
  194.  */
  195.  
  196. static void
  197. PrintTOD(arg)
  198.     ClientData arg;        /* unused */
  199. {
  200.     Time time1, time2, diff;
  201.  
  202.     Timer_GetTimeOfDay(&time1, (int *) NIL, (Boolean *) NIL);
  203.     Timer_GetRealTimeOfDay(&time2, (int *) NIL, (Boolean *) NIL);
  204.     printf("Fast: %d.%06d\n", time1.seconds, time1.microseconds);
  205.     printf("Slow: %d.%06d\n", time2.seconds, time2.microseconds);
  206.     Time_Subtract(time2, time1, &diff);
  207.     printf("diff: %d.%06d\n", diff.seconds, diff.microseconds);
  208.  
  209.     /*
  210.     Timer_GetRealTimeOfDay(&time1, (int *) NIL, (Boolean *) NIL);
  211.     Timer_GetRealTimeOfDay(&time2, (int *) NIL, (Boolean *) NIL);
  212.     Time_Subtract(time2, time1, &diff);
  213.     printf("Slow diff: %d.%06d\n", diff.seconds, diff.microseconds);
  214.     */
  215. }
  216.  
  217.  
  218. /*
  219.  *----------------------------------------------------------------------
  220.  *
  221.  * PrintVersion --
  222.  *
  223.  *    Prints the kernel's version on the console.
  224.  *
  225.  * Results:
  226.  *    None.
  227.  *
  228.  * Side effects:
  229.  *    Output is written to the display.
  230.  *
  231.  *----------------------------------------------------------------------
  232.  */
  233.  
  234. static void
  235. PrintVersion(arg)
  236.     ClientData arg;        /* unused */
  237. {
  238.     extern char *SpriteVersion();
  239.     char *v;
  240.  
  241.     v = SpriteVersion();
  242.     printf("%s\n",v);
  243. }
  244.  
  245. /*
  246.  *----------------------------------------------------------------------
  247.  *
  248.  * ResetNetworks --
  249.  *
  250.  *    Reset all network interfaces.
  251.  *
  252.  * Results:
  253.  *    None.
  254.  *
  255.  * Side effects:
  256.  *    The network interfaces are reset.
  257.  *
  258.  *----------------------------------------------------------------------
  259.  */
  260.  
  261. static void
  262. ResetNetworks(arg)
  263.     ClientData arg;        /* unused */
  264. {
  265.     int            i;
  266.     Net_Interface    *interPtr;
  267.  
  268.     i = 0; 
  269.     interPtr = Net_NextInterface(FALSE, &i);
  270.     while (interPtr != (Net_Interface *) NIL) {
  271.     Net_Reset(interPtr);
  272.     i++;
  273.     interPtr = Net_NextInterface(FALSE, &i);
  274.     }
  275. }
  276.  
  277.  
  278. /*
  279.  *----------------------------------------------------------------------
  280.  *
  281.  * VidEnable --
  282.  *
  283.  *    Wrapper to avoid casts and compiler warnings.
  284.  *
  285.  * Results:
  286.  *    None.
  287.  *
  288.  * Side effects:
  289.  *    (see Dev_VidEnable.)
  290.  *
  291.  *----------------------------------------------------------------------
  292.  */
  293.  
  294. static void
  295. VidEnable(onOff)
  296.     ClientData onOff;
  297. {
  298.     Dev_VidEnable((Boolean)onOff);
  299. }
  300.